home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr09 / hwks10.zip / SETUP.MST < prev    next >
Text File  |  1993-06-19  |  7KB  |  208 lines

  1. '$DEFINE DEBUG  ''Define for script development/debugging
  2.  
  3. '$INCLUDE 'setupapi.inc'
  4. '$INCLUDE 'msdetect.inc'
  5.  
  6. '' This lets us add progman items
  7.  
  8. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  9.  
  10. ''Dialog ID's
  11. CONST ASKQUIT       = 200
  12. CONST DESTPATH      = 300
  13. CONST EXITFAILURE   = 400
  14. CONST EXITQUIT      = 600
  15. CONST EXITSUCCESS   = 700
  16. CONST APPHELP       = 900
  17. CONST MODELESS      = 5000
  18. CONST BADPATH       = 6400
  19.  
  20.     CUIDLL$ = "mscuistf.dll"            ''Custom user interface dll
  21.     HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure
  22.  
  23.     '' Display the logo bitmap
  24.     SetBitmap CUIDLL$, 1
  25.  
  26.     '' read the .INF file
  27.     szInf$ = GetSymbolValue("STF_CWDDIR") + "SETUP.INF"
  28.     ReadInfFile szInf$
  29.  
  30.     '' query user for location to install to
  31.     DEST$="c:\hw"   ''default destination
  32.  
  33. GETPATH:
  34.     SetSymbolValue "EditTextIn", DEST$
  35.     SetSymbolValue "EditFocus", "END"
  36. GETPATHL1:
  37.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)
  38.     DEST$ = GetSymbolValue("EditTextOut")
  39.  
  40.     IF sz$ = "CONTINUE" THEN
  41.         IF IsDirWritable(DEST$) = 0 THEN
  42.             GOSUB BADPATH
  43.             GOTO GETPATHL1
  44.         END IF
  45.         UIPop 1
  46.     ELSEIF sz$ = "REACTIVATE" THEN
  47.         GOTO GETPATHL1
  48.     ELSEIF sz$ = "BACK" THEN
  49.         GOTO GETPATHL1
  50.     ELSE
  51.         GOSUB ASKQUIT
  52.         GOTO GETPATH
  53.     END IF
  54.  
  55.  
  56.  
  57.     '' specify which files from .INF file should get copied
  58.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  59.  
  60.     '' Get the application HW.EXE
  61.     AddSectionFilesToCopyList "HomeWorks", SrcDir$, DEST$
  62.  
  63.     '' Get the support DLL's
  64.     AddSectionFilesToCopyList "DLLs", SrcDir$, GetWindowsSysDir()
  65.  
  66.     '' Clean out any old copies of the DLLs hanging around elsewhere
  67.     MakeListFromSectionFilename "filenames","DLLs"
  68.     nnames%=GetListLength("filenames")
  69.  
  70.     FOR cur%=1 to nnames% STEP 1
  71.  
  72.        f$=GetListItem("filenames",cur%)
  73.        win_exist%=DoesFileExist(GetWindowsDir()+f$,femExists)
  74.        sys_exist%=DoesFileExist(GetWindowsSysDir()+f$,femExists)
  75.        IF (win_exist%=1 AND sys_exist%<>1) THEN
  76.           ''copy to file from \windows dir to \windows\system
  77.           CopyFile GetWindowsDir()+f$,GetWindowsSysDir+f$,cnoNone,0
  78.           ''delete file from \windows dir
  79.           RemoveFile GetWindowsDir()+f$,cmoForce
  80.        ELSEIF (win_exist%=1 AND sys_exist%=1) THEN
  81.           win_ver$=GetVersionOfFile(GetWindowsDir()+f$)
  82.           sys_ver$=GetVersionOfFile(GetWindowsSysDir()+f$)
  83.           IF win_ver$>sys_ver$ THEN
  84.              ''copy to file from \windows dir to \windows\system
  85.              CopyFile GetWindowsDir()+f$,GetWindowsSysDir+f$,cnoNone,0
  86.              ''delete file from \windows dir
  87.              RemoveFile GetWindowsDir()+f$,cmoForce
  88.           END IF
  89.           IF win_ver$=sys_ver$ THEN
  90.              ''copy to file from \windows dir to \windows\system
  91.              CopyFile GetWindowsDir()+f$,GetWindowsSysDir+f$,cnoNone,0
  92.              ''delete file from \windows dir
  93.              RemoveFile GetWindowsDir()+f$,cmoForce
  94.           END IF
  95.           IF win_ver$<sys_ver$ THEN
  96.              ''delete file from \windows dir
  97.              RemoveFile GetWindowsDir()+f$,cmoForce
  98.           END IF
  99.        END IF
  100.     NEXT cur%
  101.  
  102.     '' Make sure there is available disk space
  103.     '' First param is just left as "extra", because we are not
  104.     '' expanding any existing files (i.e. adding a K or two to the 
  105.     '' WIN.INI file. If you use this, add an "Extra" symbol to
  106.     '' the symbol table created by AddListitem.
  107.     '' Second Parameter identifies a symbol table that the
  108.     '' GetCopyListCost function will create for how much space
  109.     '' is used by the files to be copied to hard disk.
  110.     '' Third Parameter identifies a symbol table that the
  111.     '' GetCopyListCost function will create to identify needed
  112.     '' disk space.
  113.  
  114.     lRetVal& = GetCopyListCost ( "Extra", "FileCost", "Needed" )
  115.  
  116.     IF lRetVal& > 0 THEN
  117.       i% = DoMsgBox ("Insufficient Disk Space", "Setup", 0 )
  118.       ClearCopyList
  119.       GOTO GETPATH '' Try another directory
  120.     END IF
  121.  
  122.     '' Display billboard. "FModelessDlgProc" is the default. The
  123.     '' last parameter is irrelevant as long as it is non-zero
  124.     '' this is because we only have one billboard.
  125.  
  126.     AddToBillboardList CUIDLL$, MODELESS, "FModelessDlgProc", 1
  127.  
  128.     SetCopyGaugePosition 100, 100
  129.  
  130.     '' copy the files
  131.     CopyFilesInCopyList
  132.  
  133.     '' create a progman group
  134.     CreateProgmanGroup "HomeWorks", "", cmoNone
  135.     ShowProgmanGroup  "HomeWorks", 1, cmoNone
  136.     CreateProgmanItem "HomeWorks", "HomeWorks", MakePath(DEST$,"hw.exe"), "", cmoOverwrite
  137.     CreateProgmanItem "HomeWorks", "HomeWorks Help", "winhelp.exe "+MakePath(DEST$,"hw.hlp"), "", cmoOverwrite
  138.  
  139. QUIT:
  140.     ON ERROR GOTO ERRQUIT
  141.  
  142.     IF ERR = 0 THEN
  143.         dlg% = EXITSUCCESS
  144.     ELSEIF ERR = STFQUIT THEN
  145.         dlg% = EXITQUIT
  146.     ELSE
  147.         dlg% = EXITFAILURE
  148.     END IF
  149. QUITL1:
  150.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  151.     IF sz$ = "REACTIVATE" THEN
  152.         GOTO QUITL1
  153.     END IF
  154.     UIPop 1
  155.  
  156.     END
  157.  
  158. ERRQUIT:
  159.     i% = DoMsgBox("Setup sources were corrupted, call 555-1212!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  160.     END
  161.  
  162. BADPATH:
  163.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  164.     IF sz$ = "REACTIVATE" THEN
  165.         GOTO BADPATH
  166.     END IF
  167.     UIPop 1
  168.     RETURN
  169.  
  170. ASKQUIT:
  171.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  172.  
  173.     IF sz$ = "EXIT" THEN
  174.         UIPopAll
  175.         ERROR STFQUIT
  176.     ELSEIF sz$ = "REACTIVATE" THEN
  177.         GOTO ASKQUIT
  178.     ELSE
  179.         UIPop 1
  180.     END IF
  181.     RETURN
  182.  
  183. '*************************************************************************
  184. '**
  185. '** Purpose:
  186. '**     Appends a file name to the end of a directory path,
  187. '**     inserting a backslash character as needed.
  188. '** Arguments:
  189. '**     szDir$  - full directory path (with optional ending "\")
  190. '**     szFile$ - filename to append to directory
  191. '** Returns:
  192. '**     Resulting fully qualified path name.
  193. '*************************************************************************
  194. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  195.     IF szDir$ = "" THEN
  196.         MakePath = szFile$
  197.     ELSEIF szFile$ = "" THEN
  198.         MakePath = szDir$
  199.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  200.         MakePath = szDir$ + szFile$
  201.     ELSE
  202.         MakePath = szDir$ + "\" + szFile$
  203.     END IF
  204. END FUNCTION
  205.  
  206.  
  207.  
  208.